﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"/>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" href="../style/common.css">
    <script src="../resource/js/jquery-1.11.1.min.js"></script>
    <script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="../../app/js/common.js"></script>
</head>

<?php
    include_once '../system.back.php';
    $openId=getCurrentUserOID();
    $b = new C后台管理员();
    if(empty($openId)) exit('参数错误');

    if(substr($state,0,3)=='000'){
        $enc=substr($state,3);
        $paramArray=Tools::object2array(json_decode(urldecode($enc)));
    }

    $_GET['id'] = (isset($_GET['id']))? $_GET['id'] : $paramArray['id'];

    $认证 = $bm->生成有效链接('Seller18ZiLiao',$_GET['state']);
    $病历列表 = $bm->生成有效链接('Seller19BingliAS',$_GET['state']);
    $bm = new CUI数据中心(Page::m卖家中心_账目,$openId);
    $病历文章 = $bm->fc查病历文章($_GET['id']);
    $评论列表 = $bm->get病历文章评论列表($_GET['id'],$_GET['page'],$_GET,$_POST['keywords']);

    if(isset($_POST['add'])){
           if($_SESSION['vo用户数据']['认证'] ==1){
                echo "<script>alert('请认证您的医师身份后方可参与讨论!');</script>";
           }else{
                if($_POST['诊断'] ===''){
                    echo "<script>alert('请输入内容');</script>";
                }else{
                    $do = new Do病历文章评论();
                    $do->set_用户id($_SESSION['vo用户数据']['id']);
                    $do->set_诊断($_POST['诊断']);
                    $do->set_说明($_POST['说明']);

                    $do->data['pid'] = intval($_POST['pid']);
                    $do->set_文章id($_GET['id']);
                    $do->set_时间(Date('Y-m-d H:i:s'));
                    $do->set_表名('病历文章');

                    $插入 = $do->insert();
                    $更新评论数据 = pdo()->update("`病历文章` set `评论次数`=`评论次数`+1",array(),array('id'=>$_GET['id']));

                    //发送病例回复通知
                    if($_POST['pid']==0)
                    {
                        $receive_openID = $病历文章['openID'];
                    }else{
                        $sqlitem = "select a.*,b.`name`,b.`openID` from `病历文章评论` a LEFT JOIN `用户`  b ON(a.`用户id`= b.id) WHERE a.id=".$_POST['pid'];
                        $arritem = pdo()->selectOne($sqlitem);
                        $receive_openID = $arritem['openID'];
                    }
                    if($插入){
                        $b->ff发送病例回复通知文本消息($receive_openID,$_GET['id'],$病历文章);
                        echo "<script>alert('发表成功');location.replace(location.href);</script>";
                    }else{
                        echo "<script>alert('发表失败');location.replace(location.href);</script>";
                    }
                }

            }
    }

    $注册 = $bm->生成有效链接('register',$_GET['state']);
    $sql = "SELECT   `密码`,`认证`  from `用户`  where id = ".$_SESSION['vo用户数据']['id'];
    $个人信息 = pdo()->selectOne($sql);
    if($个人信息['密码']==""){
      echo "<script>alert('请加入爱贝医生才能查看哦');window.location.href= '".$注册."';</script>";
    }

    $认证 = $bm->生成有效链接('Seller18ZiLiao',$_GET['state']);
    if($个人信息['认证'] == 1 ||!$个人信息['认证']|| $个人信息['认证'] ==''|| $个人信息['认证'] ===''){
        echo "<script>alert('请先加入爱贝医生');window.location.href= '".$认证."';</script>";
    }

    #更新浏览数
    article_statistic(1,$_SESSION['vo用户数据']['id'],$_GET['id']);

    require_once __DIR__ . '/jssdk.php';
    $数据 = pdo()->selectColumns('public_serv_accounts',array('AppSecret','app_id'),array('id' => G_SERV_ID));
    $jssdk = new JSSDK($数据['app_id'], $数据['AppSecret']);
    $signPackage = $jssdk->getSignPackage();
?>

<body style="background-color:#FFF; ">

    <div class="header">
        <?php
            $sql = "SELECT   `认证`  from `用户`  where id = ".$_SESSION['vo用户数据']['id'];
            $个人信息2 = pdo()->selectOne($sql);
            if($个人信息2['认证']=="1" || !$个人信息2['认证'] || $个人信息2['认证'] ==''|| $个人信息2['认证'] ===''){
            echo '<a href="'.$认证.'" class="RzFalse"><span>立即认证 >></span></a>';}
        ?>
        <a href="<?= $病历列表?>"  class="return">返回</a>
        <div class="write" >参与讨论</div>
    </div>
    <!--病例-详情-->
    <div class="case_view">
        <h1><?= $病历文章['title']?></h1>
        <div class="author">
            <script type="text/javascript">
                //=点击展开关闭效果=
                function openShutManager(oSourceObj,oTargetObj,shutAble,oOpenTip,oShutTip){
                    var sourceObj = typeof oSourceObj == "string" ? document.getElementById(oSourceObj) : oSourceObj;
                    var targetObj = typeof oTargetObj == "string" ? document.getElementById(oTargetObj) : oTargetObj;
                    var openTip = oOpenTip || "";
                    var shutTip = oShutTip || "";
                    if(targetObj.style.display!="none"){
                        if(shutAble) return;
                        targetObj.style.display="none";
                        if(openTip  &&  shutTip){
                            sourceObj.innerHTML = shutTip;
                        }
                    } else {
                        targetObj.style.display="block";
                        if(openTip  &&  shutTip){
                            sourceObj.innerHTML = openTip;
                        }
                    }
                }
            </script>

            <img src="<?php if($病历文章['头像']) echo $病历文章['头像']; else echo "../cache/card_img/top_index.jpg";?>" />
            <h3><?= $病历文章['name']?></h3>
            <span><?= $病历文章['医院']?></span>
            <a href="###" onclick="openShutManager(this,'box3',false,'收起','……')">……</a>
            <div class="clear"></div>
            <p id="box3" style="display:none" style="display:block; margin-left:42px; "><?= $病历文章['description']?></p>
        </div>
        <div class="con">
            <?php
                for($i=1;$i<6;$i++){
                    if($病历文章['t'.$i]!='' && $病历文章['t'.$i]!='没有图片')echo "<img src='../".$病历文章['t'.$i]."' style='width:100%'/>";
                }

            ?>

            <div><?= $病历文章['详情']?></div>
        </div>
        <!--回复循环 begin-->
        <div class="case_view_list">
            <ul>
                <?php foreach($评论列表['result'] as $key =>$value){?>
                <li>
                    <a>
                        <div><img src='<?=$value['头像']?>' /><h4><?=$value['name']?></h4><span><?php echo substr($value['时间'],0,10)?></span></div>
                       <?php if($value['pid']==0) {
                       ?>
                           <p><?=$value['说明']?></p>
                       <?php
                       }else{
                        ?>
                           <p class="case_view_reply_return_p">回复<?=$value['pname']?>：<?=$value['说明']?></p>
                           <p class="case_view_reply_y_p"><?=$value['pname']?>：<?=$value['p说明']?></p>
                       <?php  } ?>
                    </a>
                    <div class="case_view_reply_return" pid="<?=$value['id']?>"><span>回复</span></div>
                </li>
                <?php
                 }
                ?>
            </ul>

        </div>

        <!--回复循环 end-->
        <div ><?=$评论列表['show']?></div>
           
    </div> 
    <div style="width:100%;margin:0; overflow:hidden;"><img src="../img/banquan.gif" style= " width:100%; height:250px; margin:0 auto; " alt="版权声明" /></div>
    <div id="qq" style="display:none;" class="case_view_reply">
        <div class="box">
            <form action="" method="post" style="text-align: center; width: 100%" >
                <div class="box_header">
                    <span>请输入评论内容：</span>
                    <div onclick="document.getElementById('qq').style.display='none'"></div>
                </div>
                <div class="txt">
                    <textarea name="说明" cols="" rows="" type="text" id="keyword" value="请输入互动内容…" onFocus="if(value==defaultValue){value='';this.style.color='#000'}" onBlur="if(!value){value=defaultValue;this.style.color='#DB3656'}"></textarea>
                </div>
                <div class="btn"><input type="submit" name="add"  value="发布" /></div>
                <input  type="hidden" name="pid" value="0" id="PID" />
            </form>
        </div>
    </div>



    <div style="height:30px;width:100%;background:#db3655;color:#fff;font-size:80%;line-height:30px;text-align:center;position:fixed;bottom:0px; left:0;">操作过程中如有疑问，请致电客服热线：400-825-8989
    </div>
    <script>
        $(function(){
            $(".case_view_reply_return").click(function(){
                $("#qq").show();
                $("#PID").val($(this).attr("pid"));
            })
            $(".write").click(function(){
                $("#qq").show();
                $("#PID").val(0);
            })
        });

        wx.config({
            debug: false,
            appId: '<?php echo $signPackage["appId"];?>',
            timestamp: <?php echo $signPackage["timestamp"];?>,
            nonceStr: '<?php echo $signPackage["nonceStr"];?>',
            signature: '<?php echo $signPackage["signature"];?>',
            jsApiList: [
                'onMenuShareAppMessage',
                'onMenuShareTimeline',
                'onMenuShareQQ',
                'onMenuShareWeibo',
                'onMenuShareQZone'
            ]
        });

        <?php
            $desc = mb_substr(strip_tags($病历文章['详情']), 0, 100, 'utf-8');
            $desc = str_replace('&nbsp', ' ', $desc);

            $avatar = trim($病历文章['头像']);
            if (!$avatar) {
                $avatar = G_SITE_BASE .'/business/img/default_avatar.jpg';
            }
            if (substr($avatar, 0, 4) != 'http') {
                $avatar = G_SITE_BASE .'/business/'. $avatar;
            }
        ?>
        title = '<?= $病历文章['title']?>';
        desc = '<?= $desc?>';
        links = '';
        imgUrl = '<?= $avatar?>';
        weixinShare(title, desc, links, imgUrl);
    </script>
</body>
</html>

